package com.tsing.cedap.rest.controller;

import com.tsing.cedap.common.annotations.SystemLog;
import com.tsing.cedap.common.utils.ResultUtil;
import com.tsing.cedap.common.vo.PageResult;
import com.tsing.cedap.common.vo.ResultData;
import com.tsing.cedap.rest.service.IOrderService;
import com.tsing.cedap.rest.vo.reqVo.CodeReqVo;
import com.tsing.cedap.rest.vo.reqVo.OrderPageBySchoolReqVo;
import com.tsing.cedap.rest.vo.respVo.OrderRespVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author TheTsing
 * @create 2022-03-29 10:29
 */
@Api(tags = "web端订单模块")
@RestController
@RequestMapping("/webOrder")
public class WebOrderController {

    @Autowired
    private IOrderService orderService;

    @GetMapping("/orderPage")
    @ApiOperation(value = "订单分页")
    @SystemLog(description = "订单分页")
    public ResultData<PageResult<OrderRespVo>> orderPageBySchool(@Validated OrderPageBySchoolReqVo reqVo, HttpServletRequest request) {
        return ResultUtil.success(orderService.orderPageBySchool(reqVo, request));
    }

    @GetMapping("/getOrder")
    @ApiOperation(value = "获取订单信息")
    @SystemLog(description = "获取订单信息")
    public ResultData<OrderRespVo> getOrder(@Validated CodeReqVo reqVo) {
        return ResultUtil.success(orderService.getOrderById(reqVo));
    }

}
